package com.gomyb.auth;

/**
 * @author <a href="mailto:hellohesir@gmail.com">Mr_He</a>
 * 2019/8/6 17:31
 */
public class GoogleAuthTest {

    public static void main(String[] args) {
        genSecretTest();
//        authTest();
    }


    public static void genSecretTest() {
        String secret = GoogleAuthenticator.generateSecretKey();
        String url = GoogleAuthenticator.getQRBarcodeURL("admin", "testhost", secret);
        System.out.println("Please register " + url);
        System.out.println("Secret key is " + secret);
    }

    public static void authTest() {
        long code = 598929;
        String secret = "7Q7OBHUQOP5IOMBG";

        GoogleAuthenticator ga = new GoogleAuthenticator();
        ga.setWindowSize(5);
        boolean r = ga.checkCode(secret, code);
        System.out.println("Check code = " + r);
    }
}
